﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class Controls_ZhanHui : System.Web.UI.UserControl
{
    string strSQL;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            zh_gn();

            string strSQL = "select * from Delivery  order by p_ID desc";
            SqlConnection conn = Class1.DBconnection();
            SqlDataAdapter da = new SqlDataAdapter(strSQL, conn);
            DataSet ds = new DataSet();
            da.Fill(ds);
            DataTable dt = ds.Tables[0];

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                if (ds.Tables[0].Rows[i]["p_Title"].ToString().Length > 8)
                {
                    ds.Tables[0].Rows[i]["p_Title"] = ds.Tables[0].Rows[i]["p_Title"].ToString().Substring(0, 8) + "";
                }
            }

            if (dt.Rows.Count > 0)
            {
                dl_job.DataSource = ds.Tables[0];
                dl_job.DataBind();
            }
            da.Dispose();
            ds.Dispose();
            conn.Close();
            conn.Dispose();
        }
    }
    public void zh_gn()
    {
        DataTable dt = Class1.ExecSel("select top 10 n_ID, case when len(n_Title)>12 then left(n_Title,12)+'' else n_Title end as n_Title,n_Lock,n_HomeShow,n_zhaddress,n_Img,n_Time,n_zhtime from ZhanHui where  n_Lock=0  order by n_ID desc");
        if (dt.Rows.Count > 0)
        {
            if (dt.Rows[0]["n_Img"].ToString() != "" && dt.Rows[0]["n_Img"].ToString() != null)
            {
                zh_Img.Text = "<a href='wjShow_View_" + dt.Rows[0]["n_ID"].ToString() + ".html'  target=_blank><img src=" + dt.Rows[0]["n_Img"].ToString().Trim() + " border=0 width=99 height=55/></a>";
            }

            zh_Title.Text = "<a href='wjShow_View_" + dt.Rows[0]["n_ID"].ToString() + ".html'  target=_blank>" + dt.Rows[0]["n_Title"].ToString().Trim() + "</a>";

            if (dt.Rows[0]["n_zhaddress"].ToString().Length > 10)
            {
                zh_address.Text = dt.Rows[0]["n_zhaddress"].ToString().Substring(0, 10).Trim() + "...";
            }

            zh_Time.Text = dt.Rows[0]["n_zhtime"].ToString();

            if (dt.Rows[0]["n_zhaddress"].ToString().Length > 8)
            {
                zh_address.Text = dt.Rows[0]["n_zhaddress"].ToString().Substring(0, 8).Trim() + "...";
            }
            else
            {
                zh_address.Text = dt.Rows[0]["n_zhaddress"].ToString().Trim();
            }

            strSQL = "select top 5 n_ID, case when len(n_Title)>20 then left(n_Title,20)+'' else n_Title end as n_Title,n_Lock,n_HomeShow from ZhanHui where n_Class='国内展会'and n_Lock=0  order by n_ID desc";
            IDataReader dr = Class1.GetDataReader(strSQL);
            while (dr.Read())
            {
                zh_li.Text += "<div class='hxzh-li'>·<a href='wjShow_View_" + dr["n_ID"].ToString() + ".html'  target=_blank>" + dr["n_Title"].ToString().Trim() + "</a></div>";
            }
        }
        else
        {
            zh_Time.Text = "当前没有展会信息!";
        }
    }

}
